home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / others / ole_101.zip / SCHMOO.ZIP / MISC.C < prev    next >
C/C++ Source or Header  |  1992-04-13  |  3KB  |  137 lines

  1. /*
  2.  * MISC.C
  3.  *
  4.  * Functions without any other reasonable home:
  5.  *  WindowTitleSet, RectConvertToHiMetric, RectConvertToDevice
  6.  *
  7.  * Copyright(c) Microsoft Corp. 1992 All Rights Reserved
  8.  *
  9.  */
  10.  
  11. #include <windows.h>
  12. #include <ole.h>
  13. #include "schmoo.h"
  14.  
  15.  
  16.  
  17.  
  18. /*
  19.  * WindowTitleSet
  20.  *
  21.  * Purpose:
  22.  *  Handles changing the window's caption bar depending on the file
  23.  *  that is loaded.
  24.  *
  25.  * Parameters:
  26.  *  hWnd            HWND of the window to change.
  27.  *  pszFile         LPSTR of the file loaded.
  28.  *
  29.  * Return Value:
  30.  *  none.
  31.  */
  32.  
  33. void FAR PASCAL WindowTitleSet(HWND hWnd, LPSTR pszFile)
  34.     {
  35.     char        szTitle[CCHPATHMAX];
  36.  
  37.     wsprintf(szTitle, "%s - %s", (LPSTR)rgpsz[IDS_CAPTION], pszFile);
  38.     SetWindowText(hWnd, szTitle);
  39.     return;
  40.     }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. /*
  49.  * RectConvertToHiMetric
  50.  *
  51.  * Purpose:
  52.  *  Converts the contents of a rectangle from MM_TEXT into MM_HIMETRIC
  53.  *  specifically for use in converting a RECT of a window into
  54.  *  a RECT for a METAFILEPICT structure.
  55.  *
  56.  * Parameters:
  57.  *  hWnd            HWND of the window providing the display context
  58.  *  pRect           LPRECT containing the rectangle to convert.
  59.  *
  60.  * Return Value:
  61.  *  None.
  62.  */
  63.  
  64. void FAR PASCAL RectConvertToHiMetric(HWND hWnd, LPRECT pRect)
  65.     {
  66.     HDC      hDC;
  67.     POINT    pt;
  68.  
  69.     hDC=GetDC(hWnd);
  70.     SetMapMode(hDC, MM_HIMETRIC);
  71.  
  72.     //Convert upper left corner
  73.     pt.x=pRect->left;
  74.     pt.y=pRect->top;
  75.     DPtoLP(hDC, &pt, 1);
  76.     pRect->left=pt.x;
  77.     pRect->top=-pt.y;
  78.  
  79.     //Convert lower right corner
  80.     pt.x=pRect->right;
  81.     pt.y=pRect->bottom;
  82.     DPtoLP(hDC, &pt, 1);
  83.     pRect->right=pt.x;
  84.     pRect->bottom=-pt.y;
  85.  
  86.     ReleaseDC(hWnd, hDC);
  87.     return;
  88.     }
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96. /*
  97.  * RectConvertToDevice
  98.  *
  99.  * Purpose:
  100.  *  Converts the contents of a rectangle from MM_HIMETRIC into MM_TEXT
  101.  *  specifically for use in converting a RECT of an OLE object into
  102.  *  a RECT for a window.
  103.  *
  104.  * Parameters:
  105.  *  hWnd            HWND of the window providing the display context
  106.  *  pRect           LPRECT containing the rectangle to convert.
  107.  *
  108.  * Return Value:
  109.  *  None.
  110.  */
  111.  
  112. void FAR PASCAL RectConvertToDevice(HWND hWnd, LPRECT pRect)
  113.     {
  114.     HDC      hDC;
  115.     POINT    pt;
  116.  
  117.     hDC=GetDC(hWnd);
  118.     SetMapMode(hDC, MM_HIMETRIC);
  119.  
  120.     //Convert upper left corner
  121.     pt.x=pRect->left;
  122.     pt.y=pRect->bottom;
  123.     LPtoDP(hDC, &pt, 1);
  124.     pRect->left=pt.x;
  125.     pRect->bottom=pt.y;
  126.  
  127.     //Convert lower right corner
  128.     pt.x=pRect->right;
  129.     pt.y=pRect->top;
  130.     LPtoDP(hDC, &pt, 1);
  131.     pRect->right=pt.x;
  132.     pRect->top=pt.y;
  133.  
  134.     ReleaseDC(hWnd, hDC);
  135.     return;
  136.     }
  137.